package Junit4;

import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class SaleMachineTest1 {

    @Before
    public void setUp() throws Exception {
    }

    @After
    public void tearDown() throws Exception {
    }

    @Test
    public void testOperationS1() { //售货机有零钱，有啤酒，客户投币5角，选择啤酒{
        SaleMachine saleMachine1 = new SaleMachine(1, 1, 1, 1);
        String expectedResult = "Input Information \n" + "Type: Beer; Money: 5 Jiao; Change: 0\n\n";
        assertEquals(expectedResult, saleMachine1.operation("Beer", "5J"));
    }

    @Test
    public void testOperationS2() {//售货机有零钱，没有啤酒，客户投币5角，选择啤酒
        SaleMachine saleMachine2 = new SaleMachine(1, 1, 0, 1);
        String expectedResult = "Failure Information \n" + "Beer Shortage";
        assertEquals(expectedResult, saleMachine2.operation("Beer", "5J"));
    }

    @Test
    public void testOperationS3() {//售货机有零钱，有橙汁，客户投币5角，选择橙汁{
        SaleMachine saleMachine3 = new SaleMachine(1, 1, 1, 1);
        String expectedResult = "Input Information \n" + "Type: OrangeJuice; Money: 5 Jiao; Change: 0\n\n";
        assertEquals(expectedResult, saleMachine3.operation("OrangeJuice", "5J"));
    }
    @Test
    public void testOperationS4() {//售货机有零钱，无橙汁，客户投币5角，选择橙汁{
        SaleMachine saleMachine4 = new SaleMachine(1, 1, 1, 0);
        String expectedResult = "Failure Information \n" + "Type Error";
        assertEquals(expectedResult, saleMachine4.operation("OrangeJuice", "5J"));
    }
    @Test
    public void testOperationS5() {//售货机有零钱，有橙汁和啤酒，客户投币5角，选择可乐{
        SaleMachine saleMachine5 = new SaleMachine(1, 1, 1, 1);
        String expectedResult = "Failure Information \n" + "Type Error";
        assertEquals(expectedResult, saleMachine5.operation("cola", "5J"));
    }
    @Test
    public void testOperationS6() {//售货机有零钱，有啤酒，客户投币1元，选择啤酒{
        SaleMachine saleMachine6 = new SaleMachine(1, 1, 1, 1);
        String expectedResult = "Input Information \n" + "Type: Beer; Money: 1 Yuan; Change: 5 Jiao\n\n";
        assertEquals(expectedResult, saleMachine6.operation("Beer", "1Y"));
    }
    @Test
    public void testOperationS7() {//售货机有零钱，无啤酒，客户投币1元，选择啤酒{
        SaleMachine saleMachine7 = new SaleMachine(1, 1, 0, 1);
        String expectedResult = "Failure Information \n" + "Beer Shortage";
        assertEquals(expectedResult, saleMachine7.operation("Beer", "1Y"));
    }
    @Test
    public void testOperationS8() {//售货机有零钱，有橙汁，客户投币1元，选择橙汁{
        SaleMachine saleMachine8 = new SaleMachine(1, 1, 1, 1);
        String expectedResult = "Input Information: \n" + "Type: OrangeJuice; Money: 1 Yuan; Change: 5 Jiao\n\n";
        assertEquals(expectedResult, saleMachine8.operation("OrangeJuice", "1Y"));
    }
    @Test
    public void testOperationS9() {//售货机有零钱，无橙汁，客户投币1元，选择橙汁{
        SaleMachine saleMachine9 = new SaleMachine(1, 1, 1, 0);
        String expectedResult = "Failure Information \n" + "OrangeJuice Shortage";
        assertEquals(expectedResult, saleMachine9.operation("OrangeJuice", "1Y"));
    }
    @Test
    public void testOperationS10() {//售货机有零钱，有橙汁和啤酒，客户投币1元，选择可乐{
        SaleMachine saleMachine10 = new SaleMachine(1, 1, 1, 1);
        String expectedResult = "Failure Information \n" + "Type Error";
        assertEquals(expectedResult, saleMachine10.operation("cola", "1Y"));
    }
    @Test
    public void testOperationS11() {//售货机没有5角零钱，有橙汁，客户投币1元，选择橙汁{
        SaleMachine saleMachine11 = new SaleMachine(0, 1, 1, 1);
        String expectedResult = "Failure Information \n" + "Change Shortage";
        assertEquals(expectedResult, saleMachine11.operation("OrangeJuice", "1Y"));
    }
    @Test
    public void testOperationS12() {//售货机有零钱，有橙汁，客户投币非5角或1元，选择橙汁{
        SaleMachine saleMachine12 = new SaleMachine(1, 1, 1, 1);
        String expectedResult = "Failure Information \n" + "Money Error";
        assertEquals(expectedResult, saleMachine12.operation("OrangeJuice", "0Y"));
    }
}
